package ee.maoinvest.frontend.controller.requestprocessors;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import ee.maoinvest.backend.model.data.RegularReading;
import ee.maoinvest.frontend.controller.formstringdataconverters.statisticsqueryforms.GetAllEnterprisesStatisticsThatAreHavingContractWithSubstationMainElectricityMeterBetweenGivenRegularReadingsFormConverter;
import ee.maoinvest.frontend.controller.formstringdataconverters.statisticsqueryforms.GetAllEnterprisesStatisticsBetweenGivenRegularReadingsFormConverter;
import ee.maoinvest.frontend.controller.formstringdataconverters.statisticsqueryforms.GetHelpFindingRegularReadingIDWantedFormConverter;
import ee.maoinvest.frontend.controller.formstringdataconverters.statisticsqueryforms.GetSingleEnterpriseStatisticsBetweenGivenRegularReadingFormConverter;
import ee.maoinvest.frontend.controller.formstringdataconverters.statisticsqueryforms.GetSpecificParentAndItsChildMetersEnergyConsumptionStatisticsBetweenGivenRegularReadingsFormConverter;

public class StatisticsQueryFormsRequestProcessor
{
	
	public GetHelpFindingRegularReadingIDWantedFormConverter fillGetHelpFindingRegularReadingIDWantedFormConverterWithRequestData(
			HttpServletRequest request)
	{
		GetHelpFindingRegularReadingIDWantedFormConverter getHelpFindingRegularReadingIDWantedFormConverter = 
				new GetHelpFindingRegularReadingIDWantedFormConverter();
		
		String minDate = request.getParameter("minDate");
		String maxDate = request.getParameter("maxDate");
		
		getHelpFindingRegularReadingIDWantedFormConverter.setMinDate(minDate);
		getHelpFindingRegularReadingIDWantedFormConverter.setMaxDate(maxDate);
		
		return getHelpFindingRegularReadingIDWantedFormConverter;
	}
	
	public GetSingleEnterpriseStatisticsBetweenGivenRegularReadingFormConverter 
		fillGetSingleEnterpriseStatisticsBetweenGivenRegularReadingFormConverterWithRequestData(
				HttpServletRequest request)
	{
		GetSingleEnterpriseStatisticsBetweenGivenRegularReadingFormConverter getSingleEnterpriseStatisticsBetweenGivenRegularReadingFormConverter = 
				new GetSingleEnterpriseStatisticsBetweenGivenRegularReadingFormConverter();

		String enterpriseID = request.getParameter("enterpriseID");
		String minRegularReadingID = request.getParameter("minRegularReadingID");
		String maxRegularReadingID = request.getParameter("maxRegularReadingID");
		
		HttpSession session = request.getSession();
		RegularReading latestRegularReading = (RegularReading) session.getAttribute("latestRegularReading");
		
		getSingleEnterpriseStatisticsBetweenGivenRegularReadingFormConverter.setEnterpriseID(enterpriseID);
		getSingleEnterpriseStatisticsBetweenGivenRegularReadingFormConverter.setMinRegularReadingID(minRegularReadingID);
		getSingleEnterpriseStatisticsBetweenGivenRegularReadingFormConverter.setMaxRegularReadingID(maxRegularReadingID);
		getSingleEnterpriseStatisticsBetweenGivenRegularReadingFormConverter.setLatestRegularReading(latestRegularReading);
		
		return getSingleEnterpriseStatisticsBetweenGivenRegularReadingFormConverter;
	}
	
	public GetAllEnterprisesStatisticsBetweenGivenRegularReadingsFormConverter 
		fillGetAllEnterprisesStatisticsBetweenGivenRegularReadingsFormConverterWithRequestData(
				HttpServletRequest request)
	{
		GetAllEnterprisesStatisticsBetweenGivenRegularReadingsFormConverter getAllEnterprisesStatisticsBetweenGivenRegularReadingsFormConverter = 
				new GetAllEnterprisesStatisticsBetweenGivenRegularReadingsFormConverter();
		String minRegularReadingID = request.getParameter("minRegularReadingID");
		String maxRegularReadingID = request.getParameter("maxRegularReadingID");
		HttpSession session = request.getSession();
		RegularReading latestRegularReading = (RegularReading) session.getAttribute("latestRegularReading");
		
		getAllEnterprisesStatisticsBetweenGivenRegularReadingsFormConverter.setMinRegularReadingID(minRegularReadingID);
		getAllEnterprisesStatisticsBetweenGivenRegularReadingsFormConverter.setMaxRegularReadingID(maxRegularReadingID);
		getAllEnterprisesStatisticsBetweenGivenRegularReadingsFormConverter.setLatestRegularReading(latestRegularReading);
		
		return getAllEnterprisesStatisticsBetweenGivenRegularReadingsFormConverter;
	}
	
	public GetAllEnterprisesStatisticsThatAreHavingContractWithSubstationMainElectricityMeterBetweenGivenRegularReadingsFormConverter 
		fillGetAllEnterprisesHavingContractWithSubstationMainElectricityMeterBetweenGivenRegularReadingsFormConverterWithRequestData(
			HttpServletRequest request)
	{
		GetAllEnterprisesStatisticsThatAreHavingContractWithSubstationMainElectricityMeterBetweenGivenRegularReadingsFormConverter getAllEnterprisesHavingContractWithSubstationMainElectricityMeterBetweenGivenRegularReadingsFormConverter = 
				new GetAllEnterprisesStatisticsThatAreHavingContractWithSubstationMainElectricityMeterBetweenGivenRegularReadingsFormConverter();
		String minRegularReadingID = request.getParameter("minRegularReadingID");
		String maxRegularReadingID = request.getParameter("maxRegularReadingID");
		HttpSession session = request.getSession();
		RegularReading latestRegularReading = (RegularReading) session.getAttribute("latestRegularReading");
		
		getAllEnterprisesHavingContractWithSubstationMainElectricityMeterBetweenGivenRegularReadingsFormConverter.setMinRegularReadingID(minRegularReadingID);
		getAllEnterprisesHavingContractWithSubstationMainElectricityMeterBetweenGivenRegularReadingsFormConverter.setMaxRegularReadingID(maxRegularReadingID);
		getAllEnterprisesHavingContractWithSubstationMainElectricityMeterBetweenGivenRegularReadingsFormConverter.setLatestRegularReading(latestRegularReading);
		
		return getAllEnterprisesHavingContractWithSubstationMainElectricityMeterBetweenGivenRegularReadingsFormConverter;
	}
	
	public GetSpecificParentAndItsChildMetersEnergyConsumptionStatisticsBetweenGivenRegularReadingsFormConverter 
		fillGetSpecificParentAndItsChildMetersEnergyConsumptionStatisticsBetweenGivenRegularReadingsFormConverterWithRequestData(
				HttpServletRequest request)
	{
		GetSpecificParentAndItsChildMetersEnergyConsumptionStatisticsBetweenGivenRegularReadingsFormConverter getSpecificParentAndItsChildMetersEnergyConsumptionStatisticsBetweenGivenRegularReadingsFormConverter = 
				new GetSpecificParentAndItsChildMetersEnergyConsumptionStatisticsBetweenGivenRegularReadingsFormConverter();
	
		String electricityMeterID = request.getParameter("electricityMeterID");
		String minRegularReadingID = request.getParameter("minRegularReadingID");
		String maxRegularReadingID = request.getParameter("maxRegularReadingID");
		
		HttpSession session = request.getSession();
		RegularReading latestRegularReading = (RegularReading) session.getAttribute("latestRegularReading");
		
		getSpecificParentAndItsChildMetersEnergyConsumptionStatisticsBetweenGivenRegularReadingsFormConverter.setElectricityMeterID(electricityMeterID);
		getSpecificParentAndItsChildMetersEnergyConsumptionStatisticsBetweenGivenRegularReadingsFormConverter.setMinRegularReadingID(minRegularReadingID);
		getSpecificParentAndItsChildMetersEnergyConsumptionStatisticsBetweenGivenRegularReadingsFormConverter.setMaxRegularReadingID(maxRegularReadingID);
		getSpecificParentAndItsChildMetersEnergyConsumptionStatisticsBetweenGivenRegularReadingsFormConverter.setLatestRegularReading(latestRegularReading);
		
		return getSpecificParentAndItsChildMetersEnergyConsumptionStatisticsBetweenGivenRegularReadingsFormConverter;
	}
}
